#include "soc/jh7110.h"
#include <memory>
#include <utility>
#define CONV_SRAM_SIZE (u64)2*1024*1024
#define PE_SRAM_SIZE (u64)8*1024
#define CONV_SRAM_START_ADDRESS (u64)0x0
#define PE_SRAM_START_ADDRESS (u64)CONV_SRAM_SIZE
#define DRAM_START_ADDRESS (u64)0x40000000
#define DRAM_SIZE (u64)2*1024*1024*1024

JH7110::JH7110():
    dramStartAddr(DRAM_START_ADDRESS),
    convCoreStartAddr(CONV_SRAM_START_ADDRESS),
    peCoreStartAddr(PE_SRAM_START_ADDRESS)
{
    //mem init
    dram = std::make_shared<Dram>(1024);
    convolutionCoreSram = std::make_shared<Sram>(CONV_SRAM_SIZE);
    peCoreSram = std::make_shared<Sram>(PE_SRAM_SIZE);

    //mem switch for dma
    NNE50v2MemSwitch::RamMapType memory_map;
    memory_map.insert(std::make_pair(CONV_SRAM_START_ADDRESS,
                Meminfo(convolutionCoreSram, CONV_SRAM_SIZE, 0)));
    memory_map.insert(std::make_pair(PE_SRAM_START_ADDRESS,
                Meminfo(peCoreSram, PE_SRAM_SIZE, 0)));
    memory_map.insert(std::make_pair(DRAM_START_ADDRESS,
                Meminfo(dram, DRAM_SIZE, DRAM_START_ADDRESS)));
    memSwitch = std::make_shared<NNE50v2MemSwitch>(memory_map);

    //cores init
    dma = std::make_unique<ConvDMA>(dram, memSwitch);
    convolutionCore = std::make_unique<ConvPath>(convolutionCoreSram, dram);
    peCore = std::make_unique<VectorPath_v2>(peCoreSram, dram);
}

JH7110::~JH7110()
{
}
